package com.wyp168.juc.future;

import java.util.concurrent.CompletableFuture;

/**
 * @ClassName CompletableFutureCombineMethodDemo001
 * @Description TODO
 * @Author wyp168
 * @Date 2022/9/12 20:11
 */
public class CompletableFutureCombineMethodDemo001 {
    public static void main(String[] args) {
        CompletableFuture<Integer> result = CompletableFuture.supplyAsync(() -> 10)
                .thenCombine(CompletableFuture.supplyAsync(() -> 20), (x, y) -> x + y)
                .thenCombine(CompletableFuture.supplyAsync(() -> 30), (x, y) -> x + y)
                .thenCombine(CompletableFuture.supplyAsync(() -> 40), (x, y) -> x + y);
        System.out.println(Thread.currentThread().getName() + "\t" + result.join());
    }
}
